package cn.edu.nuc.ssm.controller;

import cn.edu.nuc.ssm.entity.BbsSection;
import cn.edu.nuc.ssm.entity.BbsTopic;
import cn.edu.nuc.ssm.service.BbsSectionService;
import cn.edu.nuc.ssm.service.BbsTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by Administrator on 2017/5/11.
 */
@Controller
@RequestMapping("/topic")
public class BackTopicController {

    @Autowired
    private BbsTopicService bbsTopicService;

    @RequestMapping(value = "/tolist",method = RequestMethod.GET)
    public String tolist() {

        return "back/topic/list";
    }

    @ResponseBody
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    public List<BbsTopic> list() {

        List<BbsTopic> bbsTopicList = bbsTopicService.find();

        return bbsTopicList;
    }

    @ResponseBody
    @RequestMapping(value = "/delete",method = RequestMethod.GET)
    public String delete(Integer id){

        bbsTopicService.delete(id);

        return "success";
    }

}
